using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FytSoa.Application.Authorize;
using FytSoa.Application.Sys;
using FytSoa.Application.Sys.Dto;
using FytSoa.Common;
using FytSoa.Common.EnumHelper;
using FytSoa.Model.Sys;
using Microsoft.AspNetCore.Mvc;

namespace FytSoa.Api.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class SysCodeTypeController : ControllerBase
    {
        private readonly ISysCodeTypeService _sysCodeTypeService;
        public SysCodeTypeController(ISysCodeTypeService sysCodeTypeService)
        {
            _sysCodeTypeService= sysCodeTypeService;
        }

        /// <summary>
        /// 查询列表
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpGet, Log(LogType = LogEnum.RETRIEVE)]
        public async Task<ApiResult<List<SysCodeTypeDto>>> List() => await _sysCodeTypeService.List();

        /// <summary>
        /// 添加一条信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Log(LogType = LogEnum.ADD)]
        public async Task<ApiResult<string>> Add([FromBody] SysCodeTypeParam model) => await _sysCodeTypeService.Add(model);

        /// <summary>
        /// 修改一条信息
        /// </summary>
        /// <returns></returns>
        [HttpPut, Log(LogType = LogEnum.UPDATE)]
        public async Task<ApiResult<string>> Modify([FromBody] SysCodeTypeParam model) => await _sysCodeTypeService.Modify(model);

        /// <summary>
        /// 获得一条信息
        /// </summary>
        /// <returns></returns>
        [HttpGet("{id}"), Log(LogType = LogEnum.RETRIEVE)]
        public async Task<ApiResult<SysCodeType>> GetModel(string id) => await _sysCodeTypeService.GetModel(id);

        /// <summary>
        /// 删除，支持多条
        /// </summary>
        /// <returns></returns>
        [HttpDelete, Log(LogType = LogEnum.DELETE)]
        public async Task<ApiResult<string>> Delete([FromBody] List<string> ids) => await _sysCodeTypeService.Delete(ids);

    }
}
